
//
//  HeTongDetailVC.m
//  tristana
//
//  Created by neobug on 2021/1/6.
//  Copyright © 2021 李康. All rights reserved.
//

#import "HeTongDetailVC.h"

#import<WebKit/WebKit.h>


@interface HeTongDetailVC ()
@property (strong, nonatomic) WKWebView *mainWebView;
@end

@implementation HeTongDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.title = [self.dic valueForKey:@"title"];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
    
    self.mainWebView  = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:config];
    [self.view addSubview:self.mainWebView];
    
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *leftImg = [UIImage imageNamed:@"loginBack"];
    leftBtn.frame = CGRectMake(0, 0, leftImg.size.width, leftImg.size.height);
    [leftBtn setImage:leftImg forState:UIControlStateNormal];
    
    [leftBtn addTarget:self action:@selector(leftBarAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    
//    NSString* path = [[NSBundle mainBundle] pathForResource:[self.dic valueForKey:@"title"] ofType:@"pdf"];
    
    NSURL *url = [[NSBundle mainBundle] URLForResource:[NSString stringWithFormat:@"%@.pdf",[self.dic valueForKey:@"title"]] withExtension:nil];
    [self.mainWebView loadFileURL:url allowingReadAccessToURL:url];
 
    
}

-(void)leftBarAction:(id)sender{
     [self.navigationController popViewControllerAnimated:YES];
}

@end
